@extends('admin.layout.layout')
@section('content')

 
@component('admin.components.content.rightContent')
        @slot('rightContent')

        <div class="mt-3  mb-3  d-flex justify-content-between container-fluid">
                                                        
                <div class="col-md-4 row justify-content-between">
                    <form action="?" class="d-flex">
                        <input type="hidden" value="{{$is_trashed}}" name="trashed">
                        <input type="text" class="form-control form-control-sm col-md-9" name="keyWord" placeholder="按作者名搜索" value="{{$keyWord}}">
                        <button type="submit" class="btn btn-secondary"><i class="icon-search"></i></button>
                    </form>
                </div>

                <div class="col-md-4 row justify-content-between">
                        <select class="form-control col-md-12 category-list">
                            <option value="">全部分类(切换分类，新增数据)</option>
                            @forelse($selectData as $item)
                                <option @if(isset($category_id)&&$item->id==$category_id) selected @endif value="{{$item->id}}">{!!str_repeat("&nbsp;",($item->level-1)*5)!!}└───{{$item->category_name}}</option>
                            @empty
                                <option value="">组件未收到数据</option>
                            @endforelse

                        </select>
                </div>   
                
                <script>
                    //分类切换跳转
                    $(".category-list").change(function(){
                        window.location.href="{{url('/admin/data?category_id=')}}"+$(this).val();
                    });
                    
                </script>

                <div class="col-md-4 row justify-content-end">

                    @if($is_trashed)

                        @component('admin.components.button.button',[
                            'text'=>'恢复已选',
                            'style'=>'info',
                            'classes'=>'restore-checked mr-1',
                            'action'=>url('/admin/data/restoreChecked'),
                        ])
                        @endcomponent

                        @component('admin.components.button.href',[
                            'href'=>url('/admin/data'),
                            'text'=>'返回列表',
                            'style'=>'success'
                        ])
                        @endcomponent
                        
                    @else  

                        @if($category_id)
                            @component('admin.components.button.button',[
                                'text'=>'新增数据(当前分类)',
                                'mini'=>url('/admin/data/create?category_id='.$category_id),
                                'title'=>'新增数据(当前分类)',
                                'classes'=>'mr-1'
                            ])
                            @endcomponent
                        @endisset
                  

                        @component('admin.components.button.button',[
                            'text'=>'删除已选',
                            'style'=>'danger',
                            'classes'=>'delete-checked mr-1',
                            'action'=>url('/admin/data/deleteChecked'),
                        ])
                        @endcomponent

                        @component('admin.components.button.href',[
                            'href'=>url('/admin/data?trashed=1'),
                            'text'=>'查看回收站',
                            'style'=>'secondary'
                        ])
                        @endcomponent
                    @endif

            </div>

        </div>
        <table class="table table-striped table-hover r-0">
            <thead>
            <tr class="no-b">
                <th style="width: 30px">
                    <div class="custom-control custom-checkbox">
                        <input type="checkbox" id="checkedAll" class="custom-control-input"><label class="custom-control-label" for="checkedAll"></label>
                    </div>
                </th>
                <th>ID</th>
                <th>分类名称</th>
                <th>是否置顶</th>
                <th>是否推荐</th>
                <th>是否发布</th>
                <th>作者</th>
                <th>访问量</th>
                <th>评论数</th>
                <th>排序</th>
                <th>创建时间</th>
                <th>更新时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
                @forelse($pageListData as $item)
                    <tr>
                        <td>
                            <div class="custom-control custom-checkbox">
                                <input type="checkbox" id="checkbox{{$item->id}}" class="custom-control-input  table-checkbox"><label class="custom-control-label" for="checkbox{{$item->id}}"></label>
                            </div>
                        </td>
                        <td>{{$item->id}}</td>
                        <td>
                            <span class="badge badge-success">
                                @if ($item->category)
                                    {{$item->category->category_name}}
                                @endif
                            </span>
                        </td>
                        <td>
                            <span class="icon icon-circle s-12  mr-2 text-{{$item->is_top?'success':'danger'}}"></span>
                        </td>
                        <td>
                            <span class="icon icon-circle s-12  mr-2 text-{{$item->is_recommend?'success':'danger'}}"></span>
                        </td>
                        <td>
                            <span class="icon icon-circle s-12  mr-2 text-{{$item->is_release?'success':'danger'}}"></span>
                        </td>
                        <td>{{$item->author}}</td>
                        <td>{{$item->visit_count}}</td>
                        <td>{{$item->comment_count}}</td>
                        <td>{{$item->sort}}</td>
                        <td>{{$item->created_at}}</td>
                        <td>{{$item->updated_at}}</td>
                        
                        <td>
                            <div class="d-flex">

                                @if($is_trashed)

                                @component('admin.components.form.formButton',[
                                    'action'=>url('/admin/data/restoreChecked'),
                                    'right'=>'恢复',
                                    'title'=>'是否恢复?',
                                    'icon'=>'restore',
                                    'style'=>'info'
                                ])
                                    @slot('slot')
                                         <input type="hidden" name="id" value="{{$item->id}}">
                                    @endslot
                                @endcomponent

                                @component('admin.components.form.formButton',[
                                    'action'=>url('/admin/data/forceDeleteChecked'),
                                    'right'=>'强制删除',
                                    'title'=>'是否强制删除?',
                                    'icon'=>'delete',
                                    'style'=>'danger',
                                    'dangerMode'=>true
                                ])
                                    @slot('slot')
                                        <input type="hidden" name="id" value="{{$item->id}}">
                                    @endslot
                                @endcomponent

                            @else

                                @component('admin.components.button.hrefButton',[
                                    'mini'=>url('/admin/data',['id'=>$item->id,'method'=>'edit']),
                                    'text'=>'编辑',
                                    'title'=>'数据编辑',
                                    'titleText'=>'编辑',
                                    'icon'=>'pencil'
                                ])
                                @endcomponent

                                @component('admin.components.form.formButton',[
                                    'action'=>url('/admin/data',$item->id),
                                    'right'=>'删除',
                                    'title'=>'是否删除?',
                                    'icon'=>'delete',
                                    'style'=>'danger',
                                    'dangerMode'=>true,
                                    'method'=>'delete'
                                ])
                                @endcomponent

                            @endif

                            
                            </div>
                        </td>
                    </tr>
                @empty
                <tr>
                    <td colspan="13" align="center">没有更多了</td>
                </tr>
                @endforelse
            </tbody>
        </table>

            {{$pageListData->appends(['trashed'=>$is_trashed,'keyWord'=>$keyWord,'categort_id'=>$category_id])->links()}}
    @endslot

@endcomponent
 
  
@endsection